home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Commands / CommandLink.h < prev   
Encoding:
Text File  |  1997-06-28  |  751 b   |  46 lines  |  [TEXT/CWIE]

  1. // CommandLink.h
  2.  
  3. #ifndef CommandLink_h
  4. #define CommandLink_h
  5.  
  6. #ifndef Activator_h
  7. #include "Activator.h"
  8. #endif
  9.  
  10. template < class Protocol >
  11. class CommandLink: public Activator
  12.   {
  13.     private:
  14.         Protocol& handler;
  15.     
  16.         static Protocol *activeHandler;
  17.         
  18.     public:
  19.         CommandLink( Focus& focus, Protocol& theHandler )
  20.           : Activator( focus ),
  21.              handler( theHandler )
  22.           {}
  23.         
  24.         virtual void Activate()
  25.           {
  26.             Assert( activeHandler == 0 );
  27.             activeHandler = &handler;
  28.           }
  29.         
  30.         virtual void Deactivate()
  31.           {
  32.             Assert( activeHandler == &handler );
  33.             activeHandler = 0;
  34.           }
  35.         
  36.         static Protocol *ActiveHandler()
  37.           {
  38.             return activeHandler;
  39.           }
  40.   };
  41.  
  42. template < class Protocol >
  43. Protocol *CommandLink< Protocol >::activeHandler = 0;
  44.  
  45. #endif
  46.